//公司职位
import React, {Component} from 'react';
import {ScrollView, Text, TouchableOpacity, View,} from 'react-native';

import {companythreeStyle as styles} from '../../../../../styles';
import Icon from 'react-native-vector-icons/Ionicons';


export default class Companythree extends Component {
    //初始化模拟数据
    constructor(props) {
        //构造器只执行一次
        super(props);
    }

    render() {
        return (
            <ScrollView style={styles.comthreeall}>

                <View style={styles.comtop}>
                    <View style={styles.comicon}>
                        <Icon
                            name={'ios-pie-outline'}
                            size={17}
                            color={'#aeaeae'}/>
                        {this.props.fields === undefined ?
                            null :
                            this.fieldName(this.props.fields, 5)}
                    </View>
                    <View style={styles.comicon}>
                        <Icon
                            name={'md-person'}
                            size={17}
                            color={'#aeaeae'}/>
                        <Text style={styles.comlei}>公司人数:{this.props.xzCompany.companyScale}</Text>
                    </View>
                    <View style={styles.comicon}>
                        <Icon
                            name={'md-pricetags'}
                            size={17}
                            color={'#aeaeae'}/>
                        <Text style={styles.comlei}>{this.Nature(this.props.xzCompany.companyNature)}</Text>
                    </View>
                </View>


                {/* 公司地址 */}
                <TouchableOpacity style={styles.comcenter} activeOpacity={1}
                                  onPress={() =>
                                      this.props.navigation.navigate('Map_own', {
                                          latitude: this.props.xzCompany.companyY,
                                          longitude: this.props.xzCompany.companyX
                                      })
                                  }
                >
                    <Icon
                        name={'md-pin'}
                        size={17}
                        color={'#3d9ccc'}/>
                    <Text style={styles.comtext2}>{this.props.xzCompany.companySpace}</Text>
                    <Icon
                        name={'ios-arrow-forward'}
                        size={20}
                        color={'#949494'} style={styles.comicon3}/>
                </TouchableOpacity>


                <View style={styles.comcenter2}>
                    <Text style={styles.comtext2}>公司简介</Text>
                    <Text style={styles.comtext3}>
                        {this.props.xzCompany.companyIntro}
                    </Text>
                </View>
                <View style={styles.combottom}>
                    <Text style={styles.comtext2}>职位福利</Text>
                    <View style={styles.comh}>
                        {this.props.welfares === undefined ?
                            null :
                            this.welfareName(this.props.welfares, 3)}
                    </View>
                </View>
            </ScrollView>
        )
    }

    Nature(nature) {
        let str = "";
        if (nature == 1) {
            str = '国企';
        } else if (nature == 2) {
            str = '民营';
        } else if (nature == 3) {
            str = '外企';
        } else if (nature == 4) {
            str = '政府';
        }
        return str;
    }

    //待遇
    welfareName(List, sl) {
        let data = {
            cont: List
        }
        let arr = [];
        let s = sl;
        let length = data.cont.length
        if (length <= s) {
            s = length
        }
        for (let i = 0; i < s; i++) {
            arr.push(
                <Text key={i} style={styles.comtext5}>{data.cont[i].welfareName}</Text>
            )
        }
        return arr;
    }

    //领域
    fieldName(List, sl) {
        let data = {
            cont: List
        }
        var arr = [];
        var s = sl;
        var length = data.cont.length
        if (length <= s) {
            s = length
        }
        for (var i = 0; i < s; i++) {
            arr.push(
                <Text key={i} style={styles.comlei}>{data.cont[i].fieldName}</Text>
            )
        }
        return arr;
    }
}